<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>定位</title>
    <style>

        .box1{
            width: 200px;
            height: 200px;
            background-color: rgba(255, 165, 0, 0.8);
            position: absolute;
            /*z-index: -1;*/
        }

        .box2{
            width: 200px;
            height: 200px;
            background-color: rgba(187, 255, 170, 0.8);
            position: absolute;
            top: 50px;
            left: 50px;
        /*
            开启了定位后，可以通过z-index来设置元素的层级
                z-index的值越大，元素的层级就越高，层级越高越优先显示
                如果层级一样，则优先显示下边的元素
                z-index可以设置为负值，设置负值后定位元素将会被文档流中的元素覆盖！

            注意：
                祖先元素的层级再高，也无法盖住后代元素
        */
            z-index: 3;
        }

        .box3{
            width: 200px;
            height: 200px;
            background-color: rgba(255, 99, 71, 0.8);
            position: absolute;
            top: 100px;
            left: 100px;

            z-index: 9999;
        }

        .box4{
            position: absolute;
            width: 100px;
            height: 100px;
            top: 0;
            bottom: 0;
            left: 0;
            right: 0;
            margin: auto;
            background-color: yellow;
        }

        .box5{
            width: 300px;
            height: 300px;
            background-color: skyblue;
        }

    </style>
</head>
<body>


<div class="box1"></div>
<div class="box2"></div>
<div class="box3">
    <div class="box4"></div>
</div>

<div class="box5"></div>

</body>
</html>